<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        #banner{
            width: 3rem;
            height: 1rem;
            margin:0.5rem auto;
            border:solid 1px #000;
        }

        .banner{
            width: 3rem;
            height: 1rem;
            margin:0.5rem auto;
            border:solid 0.01rem #000;
        }
    </style>
</head>
<body>
    <div id="banner"></div>
    <div class="banner"></div>

    <script>
        let size;
        //1. rem 布局
        function adapter(){
            //改变 HTML 标签 fontSize 的值
            size = document.documentElement.clientWidth * 100 / 375;
            //设置
            document.documentElement.style.fontSize = size + 'px';
        }
        //初始化调用
        adapter();
        //绑定事件
        window.onresize = adapter;

        //2. 增大布局视口
        //获取 meta 标签
        let viewport = document.querySelector('meta[name=viewport]');

        //改变 content 的值
        viewport.setAttribute('content', 'initial-scale='+1/window.devicePixelRatio);

        size = window.devicePixelRatio * size;

        //设置
        document.documentElement.style.fontSize = size + 'px';
</script>
</body>
</html>